const goods = require('../models/good');

const getGoodList  = async function (ctx) {
    const result = await goods.getGoodsList();
    return result;
 }

const createGoods = async function (ctx) {
    const data = {
        goodsId: ctx.request.body.goodsId,
        goodsName: ctx.request.body.goodsName,
        goodsPrice: ctx.request.body.goodsPrice
    }
    const result = await goods.createGoods(data);
    return result;
}

const updateGoods = async function (ctx) {
    const data = {
        goodsName: ctx.request.body.goodsName,
        goodsPrice: ctx.request.body.goodsPrice,
        id: ctx.request.body.id
    }
    const result = await goods.updateGoods(data);
    return result;
}

const removeGooods = async function (ctx) {
    const data={
        id: ctx.request.body.id
    }
    const result = await goods.removeGooods(data);
    return result;
}

 module.exports = {
     getGoodList,
     createGoods,
     updateGoods,
     removeGooods
 }